#include <iostream>
using namespace std;

class Date
{
public:
    Date(int year = 2000, int month = 1, int day = 1)
        :_year(year)
        , _month(month)
        , _day(day)
    {}
    int GetMonthDay(int year, int month)
    {
        int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
        if (month == 2
            && (((year % 4 == 0) && (year % 100 != 0))
            || (year % 400 == 0)))
        {
            return 29;
        }
        return arr[month];
    }
    int GetDay()
    {
        int year = _year;
        int month = _month;
        int day = _day;
        int sum = 0;
        while (month != 0)
        {
            sum += GetMonthDay(year, --month);
        }
        return sum + day;
    }
    friend istream& operator>>(istream& in, Date& d);
private:
    int _year;
    int _month;
    int _day;
};
istream& operator>>(istream& in, Date& d)
{
    in >> d._year >> d._month >> d._day;
    return in;
}

int main()
{
    Date d;
    cin >> d;
    cout << d.GetDay() << endl;
    return 0;
}
